package com.lanou.zakerproject.base;

import android.graphics.Bitmap;

import com.android.volley.toolbox.ImageLoader;

/**
 * Created by dllo on 16/1/18.
 */
public class DoubleCache implements ImageLoader.ImageCache {
    DiskCache diskCache;
    MemoryCache memoryCache;

    public DoubleCache() {
        memoryCache = new MemoryCache();
        diskCache = new DiskCache();
    }

    @Override
    public Bitmap getBitmap(String url) {
        Bitmap bitmap = memoryCache.getBitmap(url);
        if (null == bitmap) {
            bitmap = diskCache.getBitmap(url);
        }
        return bitmap;
    }

    @Override
    public void putBitmap(String url, Bitmap bitmap) {
        diskCache.putBitmap(url, bitmap);
        memoryCache.putBitmap(url, bitmap);
    }
}
